<template>
  <div class="todoList">
    <CommonBtn label-name="待办事项提醒管理" v-if="!button || (button.event!='add()' && button.event!='edit()') " :buttons="buttons" @onButtonClick="onButtonClick">
      <span slot="conditions" v-for="(item,index) of conditions" :key="index" v-if="item.checked">{{item.label+":"+(item.type=='search'?item.proxy:item.value)}}</span>
    </CommonBtn>
    <CommonList ref="list" v-if="!button || (button.event!='add()' && button.event!='edit()')" :buttons="buttons"
                :columns="columns" :listUrl="listUrl" @tableSelect="tableSelect" :conditions="conditions"></CommonList>
    <search-pop-up :out-btn="button"
                   :props="columns" @close="close"
                   :out-conditions="conditions"
                   @conditionChange="conditionChange"></search-pop-up>
    <CommonExport :out-btn="button" :props="columns"
                  @close="close" :export-url="$api.API_EXPORTBACKLOG" :conditions="conditions"></CommonExport>


  </div>
</template>

<script>
  import CommonList from "../../common/CommonList"
  import CommonBtn from "../../common/CommonBtn";
  import SearchPopUp from "../../common/SearchPopUp";
  import CommonExport from "../../common/CommonExport";
  import SearchListPopUp from "../../common/SearchListPopUp";
  export default {
      name:'todoList',
      data(){
        return{
            buttons:[
                this.$config.BTNS.EXPORT,
                this.$config.BTNS.SEARCH
            ],
            listUrl: this.$api.API_MDM_BACKLOG_LIST,
            columns:[
                {
                    prop:'eventName',
                    label:'事件级别',
                    search:true,
                    type:'search',
                    columns:[
                        {
                            prop:'eventCode',
                            label:'事件Code',
                            search:true,
                            type:'text'
                        },
                        {
                            prop:'createTime',
                            label:'创建时间'
                        },
                        {
                            prop:'modifyTime',
                            label:'最后修改时间'
                        },
                        {
                            prop:'eventName',
                            label:'事件级别',
                            search:true,
                            type:'text'
                        }
                    ],
                    searchUrl:this.$api.API_SELECTBACKLOGNAME,
                    searchLabel:'查询事件级别',
                    searchProxy:'eventName',
                    searchValue:'eventName'
                },
                {
                    prop:'todoList',
                    label:'待办事项描述',
                    search:true,
                    type:'text'
                },
                {
                    prop:'linkUrl',
                    label:'链接地址',
                    search:true,
                    type:'text'
                },
                {
                    prop:'createUserName',
                    label:'创建者'
                },
                {
                    prop:'modifyUserName',
                    label:'最后修改者'
                },
                {
                    prop:'createTime',
                    label:'提醒时间'
                },
                {
                    prop:'modifyTime',
                    label:'处理时间'
                }
            ],
            button:null,
            conditions:[],
            row:{}
        }
      },
      methods:{
          onButtonClick(item) {
              if (item.event == 'edit()') {
                  if (!this.row || JSON.stringify(this.row) == '{}') {
                      this.$message.error("请选择一行数据")
                      return
                  }
              }
              if (item.event == 'add()') {
                  this.row = {}
              }

              this.button = item
          },
          editBack(item) {
              this.button = item
          },
          tableSelect(row) {
              this.row = row
              console.log(row)
          },
          conditionChange(conditions) {
              this.$refs.list.search()
          },
          close(item) {
              this.button = item
          }
      },
      components:{CommonExport, CommonList,CommonBtn,SearchPopUp,SearchListPopUp}
  }
</script>
